(function (lib, img, cjs) { var p; // shortcut to reference prototypes // library properties: lib.properties = { width: 900, height: 550, fps: 24, color: "#FFFFFF", manifest: [] }; // symbols: (lib.tick = function() { this.initialize(); // Layer 1 this.shape = new cjs.Shape(); this.shape.graphics.f("#33FF00").s().p("AlDIzQhxh9gPgMQg5gwgigaQg9gvgegGQh2gWgbgJQgmgNAAglQAAgWASgTQATgVAZAAQC4AAClCGQAxAnBEBFQBCBDAVAQQCIk0C5kLQCjjrCqihQCbiUBogiQBpghAABlQAAAIhBA4IihCNQkHDuiSDKQhrCWhzEbQgvBxgVAlQgiA5gfAAQgkAAhyh2g"); this.shape.setTransform(81.8,68.2); this.addChild(this.shape); }).prototype = p = new cjs.Container(); p.nominalBounds = new cjs.Rectangle(0,0,163.5,136.4); (lib.reset = function(mode,startPosition,loop) { this.initialize(mode,startPosition,loop,{}); // timeline functions: this.frame_0 = function() { this.stop(); } // actions tween: this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(2)); // Layer 2 this.shape = new cjs.Shape(); this.shape.graphics.f("rgba(102,102,102,0.996)").s().p("AjXNKQjdg7ininQhFhEgxhOQinkMAokyQAEgaAFgaQARhRAbhRIAIgKQAkhXAxhEQCljqEKhZQCag3CzAGIANAFICiAaQA4ASA4AZQCAA5BtBaIEKjqIAEMOIsEhzIEfj6QgPgYgagPQgjgVgfgPQhHgihLgOQh7gWh2AbQghAHgcAKQhUAehOAzIgGALIgLACQh3Blg8CRQgUAwgLArQACAGgCAHIgFAaQgbC4BTCoQBdC4C3BZQBOAnBYAKQAbAAARAJQBOABBIgMQAxgIAxgSQCYg4Bfh+IAegfQAFgLAHgIQAFgEACgHQAMgqAngTID5AnQAIAhgXAeIgEAGQgYA0goA6QgpBIhFBFQhJBIhPAsIgJALIg0AYIgFAJQgbAHgaAMQg6Aag7AQQgoAJgeAFIg4AHQg5AIg1AAQhqAAhkgbg"); this.shape.setTransform(20.2,462.9); this.shape_1 = new cjs.Shape(); this.shape_1.graphics.f("rgba(204,204,204,0.996)").s().p("AjXNKQjdg7ininQhFhEgxhOQinkMAokyQAEgaAFgaQARhRAbhRIAIgKQAkhXAxhEQCljqEKhZQCag3CzAGIANAFICiAaQA4ASA4AZQCAA5BtBaIEKjqIAEMOIsEhzIEfj6QgPgYgagPQgjgVgfgPQhHgihLgOQh7gWh2AbQghAHgcAKQhUAehOAzIgGALIgLACQh3Blg8CRQgUAwgLArQACAGgCAHIgFAaQgbC4BTCoQBdC4C3BZQBOAnBYAKQAbAAARAJQBOABBIgMQAxgIAxgSQCYg4Bfh+IAegfQAFgLAHgIQAFgEACgHQAMgqAngTID5AnQAIAhgXAeIgEAGQgYA0goA6QgpBIhFBFQhJBIhPAsIgJALIg0AYIgFAJQgbAHgaAMQg6Aag7AQQgoAJgeAFIg4AHQg5AIg1AAQhqAAhkgbg"); this.shape_1.setTransform(20.2,462.9); this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape}]}).to({state:[{t:this.shape_1}]},1).wait(1)); // Layer 1 this.shape_2 = new cjs.Shape(); this.shape_2.graphics.f("#FFFFFF").s().p("ApdIHQj7jYAAkvQAAkuD7jYQD7jYFiAAQFiAAD8DYQD7DYAAEuQAAEvj7DYQj8DYliAAQliAAj7jYgAnlkeQgyASgdA/QglBLABB6IgEAkQgCAlAHAbQAXBXBnAAQAyAAAWgoQANgYAAgbQAAghgVgYQgVgZAAgcQAAgVAdhOQAehOAAgLQAAgtgkgXQgVgPgYAAQgQAAgRAHg"); this.shape_2.setTransform(20.4,464.3); this.timeline.addTween(cjs.Tween.get(this.shape_2).wait(2)); }).prototype = p = new cjs.MovieClip(); p.nominalBounds = new cjs.Rectangle(-65.5,376,171.7,173.8); (lib.container = function() { this.initialize(); // Layer 1 this.shape = new cjs.Shape(); this.shape.graphics.f("rgba(255,255,255,0.996)").s().p("EgxKAd1MAAAg7pMBiVAAAMAAAA7pg"); this.shape.setTransform(314.7,191); this.addChild(this.shape); }).prototype = p = new cjs.Container(); p.nominalBounds = new cjs.Rectangle(0,0,629.5,382); (lib.checkBtn2 = function(mode,startPosition,loop) { this.initialize(mode,startPosition,loop,{}); // Layer 1 this.text = new cjs.Text("Check", "bold 22px 'Century Gothic'", "#666666"); this.text.textAlign = "center"; this.text.lineHeight = 18; this.text.lineWidth = 90; this.text.setTransform(46,0.5); this.shape = new cjs.Shape(); this.shape.graphics.f().s("#666666").ss(1,1,1).p("AHbCcIu1AAIAAk3IO1AAg"); this.shape.setTransform(47.5,15.6); this.shape_1 = new cjs.Shape(); this.shape_1.graphics.f("#FFFFFF").s().p("AnaCcIAAk3IO1AAIAAE3g"); this.shape_1.setTransform(47.5,15.6); this.shape_2 = new cjs.Shape(); this.shape_2.graphics.f("#E6E6E6").s().p("AnaCcIAAk3IO1AAIAAE3g"); this.shape_2.setTransform(47.5,15.6); this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape},{t:this.text,p:{color:"#666666"}}]}).to({state:[{t:this.shape_2},{t:this.shape},{t:this.text,p:{color:"#999999"}}]},1).wait(1)); }).prototype = p = new cjs.MovieClip(); p.nominalBounds = new cjs.Rectangle(-1,-1,97,33.2); (lib.bar = function() { this.initialize(); // Layer 1 this.shape = new cjs.Shape(); this.shape.graphics.lf(["#999999","#EEEEEE","#CCCCCC"],[0,0.522,1],0,-28,0,28).s().p("EhGXADlIAAnKMCMvAAAIAAHKg"); this.shape.setTransform(450.5,23); this.addChild(this.shape); }).prototype = p = new cjs.Container(); p.nominalBounds = new cjs.Rectangle(0,0,900.9,46); (lib.hit = function(mode,startPosition,loop) { this.initialize(mode,startPosition,loop,{}); // timeline functions: this.frame_0 = function() { /* stop();*/ } // actions tween: this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1)); // Layer 1 this.gapTxt = new cjs.Text("decode", "22px 'Century Gothic'", "#666666"); this.gapTxt.name = "gapTxt"; this.gapTxt.textAlign = "center"; this.gapTxt.lineHeight = 24; this.gapTxt.lineWidth = 217; this.gapTxt.setTransform(-2,-15.1); this.shape = new cjs.Shape(); this.shape.graphics.f().s("#666666").ss(2,1,1).p("AyBivMAkDAAAIAAFfMgkDAAAg"); this.shape_1 = new cjs.Shape(); this.shape_1.graphics.f("#FFFFFF").s().p("AyBCwIAAlfMAkDAAAIAAFfg"); this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape},{t:this.gapTxt}]}).wait(1)); }).prototype = p = new cjs.MovieClip(); p.nominalBounds = new cjs.Rectangle(-116.4,-18.6,232.9,37.2); (lib.gapDrag = function(mode,startPosition,loop) { this.initialize(mode,startPosition,loop,{}); // timeline functions: this.frame_0 = function() { /* stop();*/ } // actions tween: this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1)); // Layer 2 this.gapTxt = new cjs.Text("decode", "22px 'Century Gothic'", "#666666"); this.gapTxt.name = "gapTxt"; this.gapTxt.textAlign = "center"; this.gapTxt.lineHeight = 24; this.gapTxt.lineWidth = 217; this.gapTxt.setTransform(-2,-15.1); this.timeline.addTween(cjs.Tween.get(this.gapTxt).wait(1)); // Layer 1 this.shape = new cjs.Shape(); this.shape.graphics.f().s("#666666").ss(2,1,1).p("AyBivMAkDAAAIAAFfMgkDAAAg"); this.shape_1 = new cjs.Shape(); this.shape_1.graphics.f("#FFFFFF").s().p("AyBCwIAAlfMAkDAAAIAAFfg"); this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape}]}).wait(1)); }).prototype = p = new cjs.MovieClip(); p.nominalBounds = new cjs.Rectangle(-116.4,-18.6,232.9,37.2); // stage content: (lib.AlgorithmsGapFill = function(mode,startPosition,loop) { this.initialize(mode,startPosition,loop,{}); // timeline functions: this.frame_0 = function() { var gapString = "An algorithm is a set of designed to solve a specific problem. An example is an algorithm that a list of items into order. The is a tool that is used by many people to algorithms."; var startTxt = "Use the words to the right to fill in the blanks in the text above."; this.title2.textBaseline = "middle"; this.title2.y = this.title2.y+21; this.title2.font="28px Century Gothic,Futura,Arial"; this.title.textBaseline = "middle"; this.title.y = this.title.y+21; this.title.font="28px Century Gothic,Futura,Arial"; createjs.Touch.enable(stage); var gapFill = new Array; var startX = 0; var startY = 0; var dragItems = new Array; var txtX = new Array; var txtY = new Array; var txtWidth = new Array; var txtHeight = new Array; var gapsOnly2 = new Array; var txtBoxes = new Array; var dropped = 0; var matched = 0; var pieces = 0; this.tick2.visible = false; this.feedback.font = "bold 22px Century Gothic,Futura,Arial"; this.feedback.color = "#0099FF"; this.feedback.text = startTxt; this.checkBtn.visible = false; var shapes = {}; var shapes2 = new Array; var shapesGaps = new Array; var gaps = false; var that = this; setup2(); function setup2() { that.feedback.text=startTxt; gapFill = gapString.split(" "); var gapsOnly = new Array; var numGaps = 0; var gapPos = 80; for (var g = 1; g < gapFill.length; g++) { if ((gapFill[g].substr(0, 1) == "<") && (gapFill[g].substr(gapFill[g].length - 1, gapFill[g].length) == ">")) { gapsOnly[numGaps] = gapFill[g].substr(1, gapFill[g].length - 2); numGaps++; } } while (gapsOnly.length > 0) { gapsOnly2.push(gapsOnly.splice(Math.round(Math.random() * (gapsOnly.length - 1)), 1)[0]); } for (var o = 0; o < gapsOnly2.length; o++) { var dragItem = new lib.gapDrag(); dragItem.gapTxt.text = gapsOnly2[o]; dragItem.gapTxt.textBaseline = "middle"; dragItem.gapTxt.y = dragItem.gapTxt.y+15; dragItem.gapTxt.font="22px Century Gothic,Futura,Arial"; dragItem.x = 765.25; dragItem.y = gapPos; dragItem.mouseChildren = false; stage.addChild(dragItem); dragItem.name = gapsOnly2[o]; dragItem.on("mousedown", pickMe); dragItem.on("pressup", dropMe); gapPos = gapPos + 45; dragItems.push(dragItem); } arrange(); }; function pickMe(event) { event.currentTarget.addEventListener("pressmove", moveMe); stage.setChildIndex(event.currentTarget, stage.getNumChildren() - 1); startX = event.currentTarget.x; startY = event.currentTarget.y; event.currentTarget.offset = { x: event.currentTarget.x - event.stageX, y: event.currentTarget.y - event.stageY } } function moveMe(event) { event.currentTarget.x = event.stageX + event.currentTarget.offset.x; event.currentTarget.y = event.stageY + event.currentTarget.offset.y; } function dropMe(event) { event.currentTarget.removeEventListener("pressmove", moveMe); targetName = event.target.name + "Target"; var instance = shapes[targetName]; var valid = false; for (var y = 0; y < shapesGaps.length; y++) { if (hitTestInRange(shapesGaps[y], 50, 150)) { event.target.visible = false; gapFill[gapFill.indexOf("<" + (shapesGaps[y].name).replace("Target", "") + ">")] = "*" + event.target.name + "*"; valid = true; } } if (valid == false) { event.target.x = startX; event.target.y = startY; } else { dropped++; } clear(); arrange(); if (hitTestInRange(instance, 50, 150)) { matched++; } if (dropped == gapsOnly2.length) { that.checkBtn.visible = true; } } function arrange() { shapesGaps = []; for (var t = 0; t < gapFill.length; t++) { var txtBox = new createjs.Text("", "28px Century Gothic,Futura,Arial", "##666666"); txtBox.textBaseline = "alphabetic"; if ((gapFill[t].substr(0, 1) == "<") && (gapFill[t].substr(gapFill[t].length - 1, gapFill[t].length) == ">")) { txtBox.text = "________"; gaps = true; } else if ((gapFill[t].substr(0, 1) == "*") && (gapFill[t].substr(gapFill[t].length - 1, gapFill[t].length) == "*")) { txtBox.text = gapFill[t].substr(1, gapFill[t].length - 2); txtBox.color = "#00CCFF"; } else { txtBox.text = gapFill[t]; } txtBox.x = 10; txtBox.y = 80; stage.addChild(txtBox); txtBox.name = gapFill[t].substr(1, gapFill[t].length - 2) + "Target"; shapes[txtBox.name] = txtBox; shapes2.push(txtBox); if (gaps == true) { shapesGaps.push(txtBox); gaps = false; } pieces++; if (t > 0) { txtBox.x = txtX[t - 1] + txtWidth[t - 1] + 5; txtBox.y = txtY[t - 1]; } var bounds1 = txtBox.getBounds(); if ((txtBox.x + bounds1["width"]) > 600) { txtBox.x = 10; txtBox.y = txtY[t - 1] + txtHeight[t - 1] + 10; } var bounds = txtBox.getBounds(); txtX[t] = txtBox.x; txtY[t] = txtBox.y; txtWidth[t] = bounds["width"]; txtHeight[t] = bounds["height"]; } } function hitTestInRange(target, range, range2) { var bounds3 = target.getBounds(); if (stage.mouseX > target.x && stage.mouseX < target.x + bounds3["width"] && stage.mouseY > target.y - bounds3["height"] && stage.mouseY < target.y) { return true; } return false; } function clear() { for (var q = 0; q < shapes2.length; q++) { stage.removeChild(shapes2[q]); } } this.checkBtn.addEventListener("click", checkGame.bind(this)); function checkGame(event) { if (matched == gapsOnly2.length) { that.feedback.text = "You got " + gapsOnly2.length + " out of " + gapsOnly2.length + " well done!"; that.tick2.visible = true; } else { that.feedback.text = "Not quite, you got " + matched + " out of " + gapsOnly2.length + " correct, why not have another go?"; } } this.reset.addEventListener("click", resetThis.bind(this)); this.reset.addEventListener("mouseover", resetOver.bind(this)); this.reset.addEventListener("mouseout", resetOut.bind(this)); function resetThis() { clear(); clearDrags(); setup2(); that.checkBtn.visible = false; that.tick2.visible = false; } function resetOver() { this.reset.alpha = .5; } function resetOut() { this.reset.alpha = 1; } function clearDrags() { gapFill = []; gapsOnly2 = []; dropped = 0; matched = 0; for (var l = 0; l < dragItems.length; l++) { stage.removeChild(dragItems[l]); } } } // actions tween: this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1)); // titles this.title2 = new cjs.Text("KS3 COMPUTING", "32px 'Century Gothic'", "#333333"); this.title2.name = "title2"; this.title2.textAlign = "center"; this.title2.lineHeight = 34; this.title2.lineWidth = 885; this.title2.setTransform(447.5,505.4); this.title = new cjs.Text("Algorithms", "32px 'Century Gothic'", "#333333"); this.title.name = "title"; this.title.lineHeight = 34; this.title.lineWidth = 810; this.title.setTransform(5,3.4); this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.title},{t:this.title2}]}).wait(1)); // bg this.instance = new lib.bar(); this.instance.setTransform(449.5,527.4,1,1,180,0,0,450.4,23); this.instance.shadow = new cjs.Shadow("rgba(153,153,153,1)",0,0,5); this.instance_1 = new lib.bar(); this.instance_1.setTransform(449.4,23.4,1,1,0,0,0,450.4,23); this.instance_1.shadow = new cjs.Shadow("rgba(153,153,153,1)",0,0,5); this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance_1},{t:this.instance}]}).wait(1)); // activities this.checkBtn = new lib.checkBtn2(); this.checkBtn.setTransform(312.7,404,1.295,1.295,0,0,0,47.5,15.6); new cjs.ButtonHelper(this.checkBtn, 0, 1, 1); this.container = new lib.container(); this.container.setTransform(312.7,240.6,1,1,0,0,0,314.7,191); this.feedback = new cjs.Text("", "24px 'Century Gothic'"); this.feedback.name = "feedback"; this.feedback.lineHeight = 26; this.feedback.lineWidth = 476; this.feedback.setTransform(8.5,438.2); this.reset = new lib.reset(); this.reset.setTransform(676.1,421.2,0.294,0.294,0,0,0,307,307); this.tick2 = new lib.tick(); this.tick2.setTransform(529.7,465.4,0.388,0.34,0,0,0,81.8,68.2); this.shape = new cjs.Shape(); this.shape.graphics.f().s("#666666").ss(1,1,1).p("EAxLAAAMhiVAAA"); this.shape.setTransform(313.7,432.6); this.shape_1 = new cjs.Shape(); this.shape_1.graphics.f().s("#666666").ss(2,1,1).p("EAAAglFMAAAA9hIAAMq"); this.shape_1.setTransform(628.5,276.1); this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape},{t:this.tick2},{t:this.reset},{t:this.feedback},{t:this.container},{t:this.checkBtn}]}).wait(1)); // Layer 1 this.shape_2 = new cjs.Shape(); this.shape_2.graphics.f("rgba(0,153,255,0.2)").s().p("EgVOAlHMAAAhKNMAqdAAAMAAABKNg"); this.shape_2.setTransform(763.9,267.8); this.timeline.addTween(cjs.Tween.get(this.shape_2).wait(1)); }).prototype = p = new cjs.MovieClip(); p.nominalBounds = new cjs.Rectangle(446,272.4,910,560); })(lib = lib||{}, images = images||{}, createjs = createjs||{}); var lib, images, createjs;